import { specsadd, specscount, specsdelete, specsedit, specsinfo, specslist } from "../../utils/request/api.js";
export default {
    specslist_a( { commit }, payload) {
        specslist(payload).then(res => {
            if (res.code == 200 && res.list) {
                 commit('setspecslist',res.list)
            }
        })
    },
    specscount_a({ commit }) {
        specscount().then(res => {
            commit('setspecscount',res.list[0])
        })
    },
    specsadd_a({ commit }, payload) {
        specsadd(payload).then(res => {
             commit('setspecsTitle', res)
        })
    },
    specsdelete_a({ commit }, payload) {
        specsdelete(payload).then(res => {
            //把操作成功变成删除成功
            if (res.code == 200) {
                commit('setspecsTitle', {...res,msg:"删除成功"})
            }
        })
    },
    specsinfo_a({ commit }, payload) {
        specsinfo(payload).then(res => {
            //点击编辑的时候 直接把id添加到specsinfo上,是获取res.list[0]，才能得到
             commit('setspecsinfo',{...res.list[0],id:payload})
        })
    },
    specsedit_a({ commit }, payload) {
        specsedit(payload).then(res => {
            //把操作成功变成修改成功
            commit('setspecsTitle',{...res,msg:"修改成功"})
        })
    },
}